let fs = require("fs");


function wFile(url,text){
    return new Promise((resolve,reject)=>{
        fs.appendFile(url, text + "\n",(err)=>{
            if(!err){
                resolve(`写入${text}完成`);
            }else{
                reject(`写入${text}失败`)
            }
        })
    })
}

wFile("./ok.txt","床前明月光")
.then((data)=>{
    console.log(data);
    return wFile("./ok.txt","疑是地上霜");
})
.then((data)=>{
    console.log(data);
    return wFile("./ok.txt","举头望明月");
})
.then((data)=>{
    console.log(data);
    return wFile("./ok.txt","低头思故乡");
})
.then((data)=>{
    console.log(data);
})
.catch((err)=>{
    console.log(err);
});





